betting = {
	pack28:[1,3,6,10,15,21,28,36,45,55,63,69,73,75,75,73,69,63,55,45,36,28,21,15,10,6,3,1],
	pack16:[1,3,6,10,15,21,25,27,27,25,21,15,10,6,3,1],
	multiply:function(multi){
		var value = null;
		var name = null;
		var number = null;
		$("input[name^='n']").each(function(){
			value = $(this).val();
			name = $(this).attr("name");
			number = name.substring(1);
			if(!isNaN(number)){
				$(this).val(Math.floor(value*multi));
			}
		});
		betting.total();
	},
	divide:function(divide){
		var value = null;
		var name = null;
		var number = null;
		$("input[name^='n']").each(function(){
			value = $(this).val();
			name = $(this).attr("name");
			number = name.substring(1);
			if(!isNaN(number)){
				$(this).val(Math.floor(value/divide));
			}
		});
		betting.total();
	},
	removeTail:function(tail){
		var value = null;
		var name = null;
		var number = null;
		$("input[name^='n']").each(function(){
			value = $(this).val();
			name = $(this).attr("name");
			number = name.slice(-1);
			if(!isNaN(number) && number == tail){
				$(this).val(0);
			}
		});
		betting.total();
	},
	total:function(){
		var value = null;
		var name = null;
		var number = null;
		var total = 0;
		$("input[name^='n']").each(function(){
			value = parseInt($(this).val());
			name = $(this).attr("name");
			number = name.substring(1);
			if(!isNaN(number)){
				total += value;
			}
		});
		$("input[name='total']").val(total);
	},
	select:function(param){
		var value = null;
		var name = null;
		var number = null;
		$("input[name^='n']").each(function(){
			value = $(this).val();
			name = $(this).attr("name");
			number = name.substring(1);
			if(!isNaN(number)){
				$(this).val(betting.pack28[number]);
				
				if(param=='单'?number%2 == 0:
					param=='双'?number%2 == 1:
					param=='大'?number < 14:
					param=='小'?number > 13:
					param=='单小'?number > 13 || number%2 == 0 :
					param=='双大'?number < 14 || number%2 == 1 :
					param=='单大'?number < 14 || number%2 == 0 :
					param=='双小'?number > 13 || number%2 == 1 :
					param=='边'?number < 18 && number > 9 :
					param=='中'?number < 10 || number >17 :
					false){
						$(this).val(0);
				}
			}
		});
		
		betting.total();
	},
	remove:function(param){
		var value = null;
		var name = null;
		var number = null;
		$("input[name^='n']").each(function(){
			value = $(this).val();
			name = $(this).attr("name");
			number = name.substring(1);
			if(!isNaN(number)){
				if(param=='单'?number%2 == 1:
					param=='双'?number%2 == 0:
					param=='大'?number > 13:
					param=='小'?number < 14:
					param=='单小'?number < 14 && number%2 == 1 :
					param=='双大'?number > 13 && number%2 == 0 :
					param=='单大'?number > 13 && number%2 == 1 :
					param=='双小'?number < 14 && number%2 == 0:
					false){
						$(this).val(0);
				}
			}
		});
		betting.total();
	}
}
